<?php

/*

	MMetaverse - Open Metaverse Access Library

	Copyright (c) 2009 Mary Jane Soft - Marlon J. Manrique

	http://www.maryjanesoft.com
	http://www.marlonj.com

	This library is free software; you can redistribute it and/or
	modify it under the terms of the GNU Lesser General Public
	License as published by the Free Software Foundation; either
	version 2.1 of the License, or (at your option) any later version.

	This library is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
	Lesser General Public License for more details.

	You should have received a copy of the GNU Lesser General
	Public License along with this library; if not, write to the
	Free Software Foundation, Inc., 59 Temple Place, Suite 330,
	Boston, MA  02111-1307  USA

	$Id$

*/

/**
 * @package mjs.mmetaverse.manager
 */

/**
 * User Manager
 */
class MUserManager {

    /**
     * DataBase
     */
    private $db;

    /**
     * Create a User Manager
     *
     * @param MMetaverse $metaverse Current metaverse
     */
    function MUserManager(MMetaverse $metaverse) {
        $this->db = $metaverse->getDataBase('user');
    }

    /**
     * Return the user with the UUID specified
     *
     * @param MUUID $uuid The user uuid
     * @return MUser The information of the user
     */
    public function getUser(MUUID $uuid) {
        return $this->db->getUser($uuid);
    }

    /**
     * Return the user information of the user with the names specified
     *
     * @param string $firstName First Name
     * @param string $lastName Last Name
     *
     * @return MOSUser The information of the user
     */
    public function getUserInfo($firstName, $lastName) {
        return $this->db->getUserInfo($firstName, $lastName);
    }

    /**
     * Check user names and password to verify the identity
     *
     * @param string $firstName First name of the user
     * @param string $lastName Last name of the user
     * @param string $password Password of the user
     * @return boolean true if the user is valid, false otherwise
     */
    public function authenticate($firstName, $lastName, $password) {
        return $this->db->authenticate($firstName, $lastName, $password);
    }

    /**
     * Return the number of Users of the grid
     *
     * @return integer Number of user in the grid
     */
    public function getNumberOfUsers() {
        return $this->db->getNumberOfUsers();
    }

    /**
     * Return the grid users
     *
     * @return MUser[] Array with all the user of the grid
     */
    public function getUsers() {
        return $this->db->getUsers();
    }

    /**
     * Create the user specified
     *
     * @param MUser $user User to create 
     */
    public function createUser(MUser $user) {
        $this->db->createUser($user);
    }

    /**
     * Delete the user with the uuid specified 
     *
     * @param MUUID user uuid 
     */
    public function deleteUser(MUUID $uuid) {
        $this->db->deleteUser($uuid);
    }

    /**
     * Return the number of agents online
     *
     * @return integer Number of agents online
     */
    public function getNumberOfAgentsOnline() {
        return $this->db->getNumberOfAgentsOnline();
    }

    /**
     * Return the number of logins in the last month 
     *
     * @return integer Number of logins in the last month
     */
    public function getNumberOfLastMonthLogins() {
        return $this->db->getNumberOfLastMonthLogins();
    }

    /**
     * Check if the user exists
     *
     * @param MUser $user
     * @return boolean true if the user exists, false otherwise
     */
    public function userExists($user) {
        return $this->db->userExists($user);
    }
}

?>
